{include file="layout/layout" /}
<script type="text/javascript" charset="utf-8" src="__ROOT__public/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__ROOT__public/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__ROOT__public/ueditor/lang/zh-cn/zh-cn.js"></script>
<body style="background-color: #FFF; overflow: auto;">
<div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title"><a class="back" href="javascript:history.back();" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>
            <div class="subject">
                <h3>商品管理</h3>
                <h5>修改商品</h5>
            </div>
        </div>
    </div>
    <div id="explanation" class="explanation">
        <div id="checkZoom" class="title">
        <i class="fa fa-lightbulb-o"></i>
        <h4 title="提示相关设置操作时应注意的要点">操作提示</h4><span title="收起提示" id="explanationZoom"></span>
        </div>
        <ul>
        <li>必须选择商品分类</li>
        </ul>
    </div>
    <form action="goodsUpd?act=u" method='post' enctype="multipart/form-data" id='roleform'>
    <input type="hidden" name="gd_id" value="{:input('get.id')}">
    <div class="ncap-form-default">
        <dl class="row">
            <dt class="tit">
                <label>商品名称</label>
            </dt>
            <dd class="opt">
                <input class="input-txt" datatype="*" name="gd_name" value="{$goods.gd_name}" type="text" required>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label>商品价格</label>
            </dt>
            <dd class="opt">
                <input class="input-txt" datatype="/\d/" name="gd_price" value="{$goods.gd_price/100}" nullmsg="请填写商品价格" errormsg="只能输入数字" type="text" maxlength='10'> 元
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label>商品原价</label>
            </dt>
            <dd class="opt">
                <input class="input-txt" name="gd_old_price" {if $goods.gd_old_price}value="{$goods.gd_old_price/100}"{/if} type="text" maxlength='10' id='old'> 元
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label>商品分类</label>
            </dt>
            <dd class="opt">
                <select name="gd_cate_id" required>
                    <option value="0">—— 请选择 ——</option>
                    {foreach $cates as $k=>$v}
                        <option value="{$v.sg_id}" {if $v.sg_id==$goods.gd_cate_id}selected{/if}>{$v.sg_name}</option>
                    {/foreach}
                </select>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label>状态</label>
            </dt>
            <dd class="opt"><strong style='color:black'>{if $goods.gd_status==1}上架{else/}下架{/if}</strong></dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label>审核状态</label>
            </dt>
            <dd class="opt"><strong class='red'>
            {switch $goods.gd_audit}
                {case 1}通过{/case}
                {case -1}未通过{/case}
                {default /}待审核
            {/switch}</strong></dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label class="code_url">商品图片</label>
            </dt>
            <dd class="opt">
                {if $goods.gd_image_url}
                    <a href="__ROOT__{$goods.gd_image_url}"><img src="__ROOT__{$goods.gd_image_url}" width='150' height='auto' title='点击查看图片'></a>
                    <input class="input-txt valid" name="image" type="file">
                {else/}
                <input class="input-txt valid" name="image" type="file">
                {/if}
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label>商品描述</label>
            </dt>
            <dd class="opt">
                <textarea class="span12 ckeditor" id="desc" name="gd_desc">{$goods.gd_desc}</textarea>
            </dd>
        </dl>
        <div class="bot"><button id="button" style="width:96px;height:35px;background: #4FC0E8;border-radius:5px;line-height:35px;text-align: center;color:#fff;border: 0;font-size: 15px;">确认提交</button></div>
    </div> 
    </form>
</div>
<script>
    $(document).ready(function() {
        $('#roleform').Validform({
            tiptype: 3,
            beforeSubmit: function (data) {
                var old = $('#old').val();
                var res = /\d/;
                if(old && !res.test(old)){
                    $('#old').after('<span class="Validform_checktip Validform_wrong">只能输入数字</span>');
                    return false;
                }else{
                    return true;
                }
            }
        });
    })

</script>
<script>
    //实例化文本编辑器
    var editor;
    $(function() {
        //具体参数配置在  editor_config.js 中
        var options = {
            zIndex: 999,
            initialFrameWidth: "80%",
            //初化宽度
            initialFrameHeight: 400,
            //初化高度
            focus: false,
            //初始化时，是否让编辑器获得焦点true或false
            maximumWords: 99999,
            removeFormatAttributes: 'class,style,lang,width,height,align,hspace,valign',
            //允许的最大字符数 'fullscreen',
            pasteplain: false,
            //是否默认为纯文本粘贴。false为不使用纯文本粘贴，true为使用纯文本粘贴
            autoHeightEnabled: true
        };
        editor = new UE.ui.Editor(options);
        editor.render("desc");
    });
</script>
</body></html>